Use case: CRC calculation with default configuration ¶
This use case describes how to calculate a CRC with the default configuration using HAL1 and HAL2.
Note
Once the CRC peripheral is initialized, the calculation process can be started without calling the global configuration function.
The default parameters are already set:
Default polynomial
Default CRC init value
Input reversibility none
Output reversibility disabled
Sequence diagram ¶
Code snippet ¶
|
HAL1 |
HAL2 |
|---|---|
__IO uint32_t uwCRCValue = 0;
HAL_CRC_Init(&hcrc);
uwCRCValue = HAL_CRC_Calculate(&hcrc,
(uint32_t *)&aDataBuffer,
BUFFER_SIZE);
|
/* */
HAL_CRC_Init(&hCRC, HAL_CRC);
HAL_CRC_Calculate(pCRC,
&DataBuffer,
sizeof(uint32_t) * BUFFER_SIZE,
&CrcValue);
|
Key changes ¶
In HAL2, CRC calculation uses a handle initialized with an explicit instance (for example
HAL_CRC_Init(&hCRC, HAL_CRC)).In HAL2, CRC APIs can return additional statuses (for example
HAL_INVALID_PARAMandHAL_BUSY).The calculation call signature differs (buffer pointer and size in bytes, and output value provided as a parameter).

